import http from '@/utils/http'

const BASE_URL = '/testing/apiModule'

export interface ApiModuleResp {
  id: string
  projectId: string
  name: string
  version: string
  status: string
  isDeleted: string
  createdBy: string
  updatedBy: string
  createdAt: string
  updatedAt: string
  createUserString: string
  updateUserString: string
}
export interface ApiModuleDetailResp {
  id: string
  projectId: string
  name: string
  version: string
  status: string
  isDeleted: string
  createdBy: string
  updatedBy: string
  createdAt: string
  updatedAt: string
  createUserString: string
  updateUserString: string
}
export interface ApiModuleQuery {
  version: string
  createdBy: string
  sort: Array<string>
}
export interface ApiModulePageQuery extends ApiModuleQuery, PageQuery {}

/** @desc 查询接口模块列表 */
export function listApiModule(query: ApiModulePageQuery) {
  return http.get<PageRes<ApiModuleResp[]>>(`${BASE_URL}`, query)
}

/** @desc 查询接口模块详情 */
export function getApiModule(id: string) {
  return http.get<ApiModuleDetailResp>(`${BASE_URL}/${id}`)
}

/** @desc 新增接口模块 */
export function addApiModule(data: any) {
  return http.post(`${BASE_URL}`, data)
}

/** @desc 修改接口模块 */
export function updateApiModule(data: any, id: string) {
  return http.put(`${BASE_URL}/${id}`, data)
}

/** @desc 删除接口模块 */
export function deleteApiModule(id: string) {
  return http.del(`${BASE_URL}/${id}`)
}

/** @desc 导出接口模块 */
export function exportApiModule(query: ApiModuleQuery) {
  return http.download<any>(`${BASE_URL}/export`, query)
}
